package com.yf.course.modules.course.dto;

import com.yf.base.api.annon.Dict;
import com.yf.system.utils.HtmlUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
* <p>
* 课程信息数据传输类
* </p>
*
* @author 聪明笨狗
* @since 2020-12-17 11:28
*/
@Data
@ApiModel(value="课程信息", description="课程信息")
public class CourseDTO implements Serializable {


    private static final long serialVersionUID = 1L;


    @ApiModelProperty(value = "ID", required=true)
    private String id;

    @ApiModelProperty(value = "课程名称", required=true)
    private String title;

    @ApiModelProperty(value = "课程描述", required=true)
    private String content;

    @ApiModelProperty(value = "课程封面", required=true)
    private String cover;

    @Dict(dicCode = "open_type")
    @ApiModelProperty(value = "1公开,2定员", required=true)
    private Integer openType;
    private String openType_dictText;

    @Dict(dicCode = "course_catalog")
    @ApiModelProperty(value = "分类", required=true)
    private String catId;
    private String catId_dictText;

    @Dict(dictTable = "el_course_lecturer", dicText = "name", dicCode = "id")
    @ApiModelProperty(value = "讲师", required=true)
    private String lecturerId;
    private String lecturerId_dictText;

    @ApiModelProperty(value = "课时", required=true)
    private Integer periods;

    @ApiModelProperty(value = "是否必修", required=true)
    private Boolean isMust;

    @ApiModelProperty(value = "考试积分", required=true)
    private Integer points;

    @ApiModelProperty(value = "课程售价")
    private BigDecimal price;

    @ApiModelProperty(value = "定时弹窗校验")
    private Boolean checkOn;

    @ApiModelProperty(value = "弹窗间隔")
    private Integer checkSec;

    @ApiModelProperty(value = "视频拖动")
    private Boolean videoDrag;

    @ApiModelProperty(value = "部门编码")
    private String deptCode;

    @Dict(dicCode = "state")
    @ApiModelProperty(value = "0正常1禁用2未开始3已结束")
    private Integer state;
    private String state_dictText;

    @ApiModelProperty(value = "开启时间")
    private Date startTime;

    @ApiModelProperty(value = "结束时间")
    private Date endTime;

    @ApiModelProperty(value = "每天限学分钟数", required=true)
    private Integer dayLimit;

    @ApiModelProperty(value = "每天学习时段", required=true)
    private String dayRule;

    @ApiModelProperty(value = "刷脸开始学习", required=true)
    private Boolean faceStart;

    @ApiModelProperty(value = "抓拍间隔", required=true)
    private Integer faceInterval;

    @ApiModelProperty(value = "人脸二次校验", required=true)
    private Boolean faceCheck;

    @ApiModelProperty(value = "开启摄像头抓拍", required=true)
    private Boolean faceCam;

    @ApiModelProperty(value = "失败退出次数", required=true)
    private Integer faceChance;

    @ApiModelProperty(value = "顺序解锁", required=true)
    private Boolean stepLock;

    @ApiModelProperty(value = "关联考试", required=true)
    private String refExam;

    @ApiModelProperty(value = "创建时间", required=true)
    private Date createTime;

    @ApiModelProperty(value = "更新时间", required=true)
    private Date updateTime;

    @ApiModelProperty(value = "创建人", required=true)
    private String createBy;

    @ApiModelProperty(value = "修改人", required=true)
    private String updateBy;

    @ApiModelProperty(value = "数据标识", required=true)
    private Integer dataFlag;

    @ApiModelProperty(value = "当前用户是否可见", required=false)
    private Boolean isCurrentVisible;
    /**
     * 获取内容文本
     * @return
     */
    public String getContentText(){
        if(StringUtils.isBlank(this.content)){
            return this.title;
        }
        String text = HtmlUtils.splitAndFilterString(this.content, 160);
        if(StringUtils.isBlank(text)){
            return this.title;
        }
        return text;

    }

}
